# -*- mode: org; -*-
#+TITLE: How to install Nitrogen
#+AUTHOR: Zelphir Kaltstahl
#+EMAIL: zelphirkaltstahl@posteo.de
#+STARTUP: content indent align inlineimages hideblocks entitiesplain nologdone nologreschedule nologredeadline nologrefile
#+TODO: TODO WIP DEPRECATED | DONE
#+DATE: <2021-06-20 Sun>
#+KEYWORDS: erlang nitrogen install guide
#+LANGUAGE: English
#+PRIORITIES: A E E
#+EXCLUDE_TAGS: noexport
#+OPTIONS: ^:{}
#+OPTIONS: H:10
#+OPTIONS: toc:2
#+OPTIONS: tags:nil
#+OPTIONS: tasks:t
#+OPTIONS: H:6
#+OPTIONS: p:nil
#+OPTIONS: pri:nil
#+OPTIONS: prop:nil
#+OPTIONS: todo:t
#+OPTIONS: stat:nil
#+OPTIONS: |:t
#+OPTIONS: inline:nil
#+OPTIONS: date:t


* Install Erlang

  2 options:

** GNU Guix

#+begin_src shell
guix install erlang
#+end_src

** Install from source using kerl

TODO

* Install Nitrogen

** Install from source

*** Cleanup

#+header: :var PROJECT_NAME="testproj"
#+header: :var REPO_DIR="nitrogen"
#+begin_src shell :results outputs verbatim drawer replace
rm --verbose --recursive "${REPO_DIR}" "${PROJECT_NAME}"
#+end_src

#+RESULTS:
:results:
:end:

*** Cloning

#+header: :var REPO_DIR="nitrogen"
#+begin_src shell :results outputs verbatim drawer replace
git clone git://github.com/nitrogen/nitrogen "${REPO_DIR}"
#+end_src

#+RESULTS:
:results:
:end:

*** Building

#+header: :var PROJECT_NAME="testproj"
#+header: :var REPO_DIR="nitrogen"
#+begin_src shell :results outputs verbatim drawer replace
pushd "${REPO_DIR}"
make rel_inets PROJECT="${PROJECT_NAME}"
#+end_src

#+RESULTS:
:results:
~/dev/erlang/build-it-with-nitrogen/00-install/nitrogen ~/dev/erlang/build-it-with-nitrogen/00-install
make[1]: Entering directory '/home/xiaolong/dev/erlang/build-it-with-nitrogen/00-install/nitrogen'
./rebar get-deps
==> rel (get-deps)
==> nitrogen (get-deps)
./rebar compile
==> rel (compile)
==> nitrogen (compile)
make[2]: Entering directory '/home/xiaolong/dev/erlang/build-it-with-nitrogen/00-install/nitrogen'
make[2]: Leaving directory '/home/xiaolong/dev/erlang/build-it-with-nitrogen/00-install/nitrogen'
********************************************************************************
Creating full release in ../testproj with inets
********************************************************************************
make[2]: Entering directory '/home/xiaolong/dev/erlang/build-it-with-nitrogen/00-install/nitrogen'
make[3]: Entering directory '/home/xiaolong/dev/erlang/build-it-with-nitrogen/00-install/nitrogen'
==> rel (generate)
Copying /gnu/store/naf8zgv7svpiqan2accjadm5v6bas1ad-erlang-23.2.1/lib/erlang/lib/erl_interface-4.0.1
Generating "nitrogen/rebar.config"
make[4]: Entering directory '/home/xiaolong/dev/erlang/build-it-with-nitrogen/00-install/nitrogen/rel/nitrogen'
Using Erlang in /home/xiaolong/dev/erlang/build-it-with-nitrogen/00-install/nitrogen/rel/nitrogen/erts-11.1.5/bin/erl
==> site (get-deps)
==> nitrogen (get-deps)
Pulling mimetypes from {git,"git://github.com/spawngrid/mimetypes.git",
                            {branch,master}}
Cloning into 'mimetypes'...
Pulling simple_bridge from {git,"git://github.com/nitrogen/simple_bridge",
                                {branch,master}}
Cloning into 'simple_bridge'...
Pulling qdate from {git,"git://github.com/choptastic/qdate",{branch,master}}
Cloning into 'qdate'...
Pulling nprocreg from {git,"git://github.com/nitrogen/nprocreg",
                           {branch,master}}
Cloning into 'nprocreg'...
Pulling nitrogen_core from {git,"git://github.com/nitrogen/nitrogen_core",
                                {branch,master}}
Cloning into 'nitrogen_core'...
Pulling sync from {git,"git://github.com/rustyio/sync",{branch,master}}
Cloning into 'sync'...
Pulling nitro_cache from {git,"git://github.com/nitrogen/nitro_cache",
                              {branch,master}}
Cloning into 'nitro_cache'...
==> mimetypes (get-deps)
==> simple_bridge (get-deps)
Pulling stacktrace_compat from {git,"git://github.com/g-andrade/stacktrace_compat",
                                    {tag,"1.0.1"}}
Cloning into 'stacktrace_compat'...
==> stacktrace_compat (get-deps)
==> qdate (get-deps)
Pulling erlware_commons from {git,"git://github.com/erlware/erlware_commons",
                                  {tag,"v1.5.0"}}
Cloning into 'erlware_commons'...
Pulling qdate_localtime from {git,"git://github.com/choptastic/qdate_localtime",
                                  {tag,"1.1.0"}}
Cloning into 'qdate_localtime'...
==> erlware_commons (get-deps)
Pulling cf from {git,"https://github.com/project-fifo/cf",{tag,"0.2.2"}}
Cloning into 'cf'...
==> cf (get-deps)
==> qdate_localtime (get-deps)
==> nitro_cache (get-deps)
==> nprocreg (get-deps)
==> nitrogen_core (get-deps)
Pulling rekt from {git,"git://github.com/nitrogen/rekt",{branch,master}}
Cloning into 'rekt'...
==> rekt (get-deps)
==> sync (get-deps)
Pulling fs from {git,"https://github.com/synrc/fs",{tag,"6.1"}}
Cloning into 'fs'...
==> fs (get-deps)
Checking for Nitrogen Plugins
No Nitrogen Plugins Found
Using Erlang in /home/xiaolong/dev/erlang/build-it-with-nitrogen/00-install/nitrogen/rel/nitrogen/erts-11.1.5/bin/erl
==> mimetypes (compile)
Compiled src/mimetypes_scan.xrl
Compiled src/mimetypes_parse.yrl
Compiled src/mimetypes_sup.erl
Compiled src/mimetypes_loader.erl
Compiled src/mimetypes_app.erl
Compiled src/mimetypes_parse.erl
Compiled src/mimetypes_scan.erl
Compiled src/mimetypes.erl
==> stacktrace_compat (compile)
Compiled src/stacktrace_transform.erl
==> simple_bridge (compile)
Generating compatibility for simple_bridge...
...?HASH/1 => "crypto:hash(sha, Data)"
...?MAPS_FILTER/2 => "maps:filter(Pred, Map)"
...?RAND_UNIFORM/1 => "crypto:rand_uniform(1, Max)"
...?PARSE_QS/1 => "uri_string:dissect_query(String)"
...writing "include/compat.hrl"
Compiled src/simple_bridge_handler.erl
Compiled src/simple_bridge.erl
Compiled src/yaws_bridge_modules/yaws_simple_bridge_sup.erl
Compiled src/yaws_bridge_modules/yaws_simple_bridge_anchor.erl
Compiled src/webmachine_bridge_modules/webmachine_simple_bridge_sup.erl
Compiled src/webmachine_bridge_modules/webmachine_simple_bridge_anchor.erl
Compiled src/yaws_bridge_modules/yaws_simple_bridge.erl
Compiled src/webmachine_bridge_modules/webmachine_simple_bridge_static.erl
Compiled src/webmachine_bridge_modules/webmachine_simple_bridge.erl
Compiled src/simple_bridge_util.erl
Compiled src/simple_bridge_handler_sample.erl
Compiled src/simple_bridge_app.erl
Compiled src/simple_bridge_websocket.erl
Compiled src/sb_uploaded_file.erl
Compiled src/simple_bridge_multipart.erl
Compiled src/mochiweb_bridge_modules/mochiweb_simple_bridge_sup.erl
Compiled src/sb_file_upload_handler.erl
Compiled src/mochiweb_bridge_modules/mochiweb_simple_bridge_anchor.erl
Compiled src/inets_bridge_modules/inets_simple_bridge_sup.erl
Compiled src/mochiweb_bridge_modules/mochiweb_simple_bridge.erl
Compiled src/inets_bridge_modules/inets_simple_bridge_anchor.erl
Compiled src/cowboy_bridge_modules/cowboy_simple_bridge_sup.erl
Compiled src/sbw.erl
Compiled src/inets_bridge_modules/inets_simple_bridge.erl
Compiled src/cowboy_bridge_modules/cowboy_request_server.erl
Compiled src/cowboy_bridge_modules/cowboy_simple_bridge_anchor.erl
Compiled src/cowboy_bridge_modules/cowboy_simple_bridge.erl
==> cf (compile)
Compiled src/cf.erl
Compiled src/cf_term.erl
==> erlware_commons (compile)
Compiled src/ec_vsn.erl
Compiled src/ec_dictionary.erl
Compiled src/ec_talk.erl
Compiled src/ec_semver.erl
Compiled src/ec_semver_parser.erl
Compiled src/ec_orddict.erl
Compiled src/ec_lists.erl
Compiled src/ec_rbdict.erl
Compiled src/ec_gb_trees.erl
Compiled src/ec_git_vsn.erl
Compiled src/ec_dict.erl
Compiled src/ec_file.erl
Compiled src/ec_compile.erl
Compiled src/ec_cnv.erl
Compiled src/ec_plists.erl
Compiled src/ec_cmd_log.erl
Compiled src/ec_assoc_list.erl
Compiled src/ec_date.erl
==> qdate_localtime (compile)
Compiled src/ibuild.erl
/home/xiaolong/dev/erlang/build-it-with-nitrogen/00-install/nitrogen/rel/nitrogen/lib/qdate_localtime/src/localtime_dst.erl:16: Warning: export_all flag enabled - all functions will be exported
Compiled src/localtime_dst.erl
Compiled src/localtime.erl
==> qdate (compile)
Compiled src/qdate_srv.erl
Compiled src/qdate.erl
==> nitro_cache (compile)
Compiled src/nitro_cache_sup.erl
Compiled src/nitro_cache_app.erl
Compiled src/nitro_cache_expirer.erl
Compiled src/nitro_cache_mutex.erl
Compiled src/nitro_cache.erl
==> nprocreg (compile)
Compiled src/nprocreg_sup.erl
Compiled src/nprocreg_app.erl
Compiled src/nprocreg.erl
==> rekt (compile)
Compiled src/rekt.erl
==> nitrogen_core (compile)
Generating compatibility macros...
...?WF_ENCRYPT will use: "crypto:crypto_one_time(aes_128_cbc, Key, IV, Data, true)"
...?WF_DECRYPT will use: "crypto:crypto_one_time(aes_128_cbc, Key, IV, Data, false)"
...?WF_HASH will use:    "crypto:hash(sha, Data)"
...?WF_UNIQUE will use:  "erlang:unique_integer([positive])"
...?WF_RAND_UNIFORM/1 will use: "rand:uniform(Max)"
...?WF_RAND_UNIFORM/2 will use: "(rand:uniform(Max-Min+1)+Min-1)"
...?WF_PARSE_QS/1 will use: "uri_string:dissect_query(String)"
...writing "include/compat.hrl"
Compiled src/handlers/security/security_handler.erl
Compiled src/handlers/identity/identity_handler.erl
Compiled src/handlers/process_registry/process_registry_handler.erl
Compiled src/handlers/log/log_handler.erl
Compiled src/handlers/postback/postback_handler.erl
Compiled src/handlers/query/query_handler.erl
Compiled src/handlers/config/config_handler.erl
Compiled src/handlers/session/session_handler.erl
Compiled src/handlers/route/route_handler.erl
Compiled src/handlers/cache/cache_handler.erl
Compiled src/handlers/state/state_handler.erl
Compiled src/handlers/crash/crash_handler.erl
Compiled src/handlers/role/role_handler.erl
Compiled src/validators/validator_min_length.erl
Compiled src/validators/validator_max_length.erl
Compiled src/wf_core.erl
Compiled src/wf.erl
Compiled src/validators/validator_js_custom.erl
Compiled src/validators/validator_is_required.erl
Compiled src/validators/validator_is_number.erl
Compiled src/validators/validator_is_integer.erl
Compiled src/validators/validator_is_email.erl
Compiled src/validators/validator_custom.erl
Compiled src/validators/validator_confirm_password.erl
Compiled src/validators/validator_confirm_same.erl
Compiled src/nitrogen.erl
Compiled src/nitrogen_dev.erl
Compiled src/lib/wf_validation.erl
Compiled src/lib/wf_utils.erl
Compiled src/lib/wf_test_srv.erl
Compiled src/lib/wf_test.erl
Compiled src/lib/wf_security_policy.erl
Compiled src/lib/wf_tags.erl
Compiled src/lib/wf_render_elements.erl
Compiled src/lib/wf_render_actions.erl
Compiled src/lib/wf_pickle.erl
Compiled src/lib/wf_pandoc.erl
Compiled src/lib/wf_handler.erl
Compiled src/lib/wf_event.erl
Compiled src/lib/wf_cookies.erl
Compiled src/lib/wf_action_queue.erl
Compiled src/lib/wf_context.erl
Compiled src/lib/nitro_mochinum.erl
Compiled src/handlers/state/default_state_handler.erl
Compiled src/handlers/session/simple_session_handler.erl
Compiled src/lib/wf_convert.erl
Compiled src/handlers/security/http_basic_auth_security_handler.erl
Compiled src/handlers/security/default_security_handler.erl
Compiled src/handlers/route/nitrogen_smart_extensions.erl
Compiled src/handlers/route/passthrough_route_handler.erl
Compiled src/handlers/route/nitrogen_rest.erl
Compiled src/handlers/route/file_not_found_page.erl
Compiled src/handlers/route/named_route_handler.erl
Compiled src/handlers/role/default_role_handler.erl
Compiled src/handlers/route/dynamic_route_handler.erl
Compiled src/handlers/query/default_query_handler.erl
Compiled src/lib/nitro_mochijson2.erl
Compiled src/handlers/process_registry/nprocreg_registry_handler.erl
Compiled src/handlers/postback/default_postback_handler.erl
Compiled src/handlers/log/default_log_handler.erl
Compiled src/handlers/identity/default_identity_handler.erl
Compiled src/handlers/crash/default_crash_handler.erl
Compiled src/handlers/crash/debug_crash_handler.erl
Compiled src/handlers/config/default_config_handler.erl
Compiled src/handlers/cache/default_cache_handler.erl
Compiled src/elements/table/element_tablerow.erl
Compiled src/elements/table/element_tableheader.erl
Compiled src/elements/table/element_tablecell.erl
Compiled src/elements/table/element_table.erl
Compiled src/elements/table/element_singlerow.erl
Compiled src/handlers/process_registry/gproc_registry_handler.erl
Compiled src/elements/other/element_youtube.erl
Compiled src/elements/other/element_video.erl
Compiled src/elements/other/element_sync_panel.erl
Compiled src/elements/other/element_spinner.erl
Compiled src/elements/other/element_sortitem.erl
Compiled src/elements/other/element_sparkline.erl
Compiled src/elements/other/element_sortblock.erl
Compiled src/elements/other/element_qr.erl
Compiled src/elements/other/element_progress_bar.erl
Compiled src/elements/other/element_recaptcha.erl
Compiled src/elements/other/element_mermaid.erl
Compiled src/elements/other/element_iframe.erl
Compiled src/elements/other/element_gravatar.erl
Compiled src/elements/other/element_function.erl
Compiled src/elements/other/element_flash.erl
Compiled src/elements/other/element_file.erl
Compiled src/elements/other/element_droppable.erl
Compiled src/elements/other/element_google_chart.erl
Compiled src/elements/other/element_draggable.erl
Compiled src/elements/other/element_delay_body.erl
Compiled src/elements/mobile/element_mobile_toggle.erl
Compiled src/elements/mobile/element_mobile_panel.erl
Compiled src/elements/other/element_bind.erl
Compiled src/elements/mobile/element_mobile_listitem.erl
Compiled src/elements/mobile/element_mobile_list_divider.erl
Compiled src/elements/mobile/element_mobile_list.erl
Compiled src/elements/mobile/element_mobile_grid_block.erl
Compiled src/elements/mobile/element_mobile_grid.erl
Compiled src/elements/mobile/element_mobile_collapsible_set.erl
Compiled src/elements/mobile/element_mobile_collapsible.erl
Compiled src/elements/layout/element_placeholder.erl
Compiled src/elements/layout/element_panel.erl
Compiled src/elements/layout/element_lightbox.erl
Compiled src/elements/layout/element_template.erl
Compiled src/elements/layout/element_h.erl
Compiled src/elements/layout/element_grid.erl
Compiled src/elements/layout/element_fieldset.erl
Compiled src/elements/html5/element_time.erl
Compiled src/elements/html5/element_section.erl
Compiled src/elements/html5/element_nav.erl
Compiled src/elements/html5/element_mark.erl
Compiled src/elements/html5/element_main.erl
Compiled src/elements/html5/element_html5_header.erl
Compiled src/elements/html5/element_html5_footer.erl
Compiled src/elements/html5/element_aside.erl
Compiled src/elements/html5/element_article.erl
Compiled src/elements/html/element_value.erl
Compiled src/elements/html/element_strong.erl
Compiled src/elements/html/element_span.erl
Compiled src/elements/html/element_pre.erl
Compiled src/elements/html/element_literal.erl
Compiled src/elements/html/element_p.erl
Compiled src/elements/html/element_listitem.erl
Compiled src/elements/html/element_list.erl
Compiled src/elements/html/element_image.erl
Compiled src/elements/html/element_link.erl
Compiled src/elements/html/element_hr.erl
Compiled src/elements/html/element_email_link.erl
Compiled src/elements/html/element_em.erl
Compiled src/elements/html/element_br.erl
Compiled src/elements/forms/element_textbox_autocomplete.erl
Compiled src/elements/forms/element_wizard.erl
Compiled src/elements/forms/element_upload.erl
Compiled src/elements/forms/element_restful_upload.erl
Compiled src/elements/forms/element_textbox.erl
Compiled src/elements/forms/element_textarea.erl
Compiled src/elements/forms/element_restful_submit.erl
Compiled src/elements/forms/element_restful_reset.erl
Compiled src/elements/forms/element_restful_form.erl
Compiled src/elements/forms/element_range.erl
Compiled src/elements/forms/element_radiogroup.erl
Compiled src/elements/forms/element_password.erl
Compiled src/elements/forms/element_label.erl
Compiled src/elements/forms/element_radio.erl
Compiled src/elements/forms/element_inplace_textbox.erl
Compiled src/elements/forms/element_inplace_textarea.erl
Compiled src/elements/forms/element_inplace.erl
Compiled src/elements/forms/element_hidden.erl
Compiled src/elements/forms/element_datepicker_textbox.erl
Compiled src/elements/forms/element_dropdown.erl
Compiled src/elements/forms/element_checkbox.erl
Compiled src/elements/forms/element_date_dropdown.erl
Compiled src/elements/forms/element_button.erl
Compiled src/actions/action_validation_error.erl
Compiled src/actions/action_wire.erl
Compiled src/actions/action_validate.erl
Compiled src/actions/action_toggle_option.erl
Compiled src/actions/action_update.erl
Compiled src/actions/action_toggle_mobile_panel.erl
Compiled src/actions/action_toggle.erl
Compiled src/actions/action_slide_up.erl
Compiled src/actions/action_slide_down.erl
Compiled src/actions/action_show.erl
Compiled src/actions/action_set_multiple.erl
Compiled src/actions/action_set_cookie.erl
Compiled src/actions/action_set.erl
Compiled src/actions/action_script.erl
Compiled src/actions/action_remove_option.erl
Compiled src/actions/action_remove_class.erl
Compiled src/actions/action_redirect.erl
Compiled src/actions/action_make_writable.erl
Compiled src/actions/action_open_window.erl
Compiled src/actions/action_make_readonly.erl
Compiled src/actions/action_js_fun.erl
Compiled src/actions/action_if_value.erl
Compiled src/actions/action_jquery_effect.erl
Compiled src/actions/action_hide.erl
Compiled src/actions/action_function.erl
Compiled src/actions/action_fade.erl
Compiled src/actions/action_enable.erl
Compiled src/actions/action_event.erl
Compiled src/actions/action_effect.erl
Compiled src/actions/action_disable_selection.erl
Compiled src/actions/action_disable.erl
Compiled src/actions/action_console_log.erl
Compiled src/actions/action_confirm.erl
Compiled src/actions/action_continue.erl
Compiled src/actions/action_click.erl
Compiled src/actions/action_clear_validation.erl
Compiled src/actions/action_buttonize.erl
Compiled src/actions/action_before_postback.erl
Compiled src/actions/action_appear.erl
Compiled src/actions/action_api.erl
Compiled src/actions/action_animate.erl
Compiled src/actions/action_alert.erl
Compiled src/actions/action_comet.erl
Compiled src/actions/action_add_option.erl
Compiled src/actions/action_add_class.erl
==> fs (compile)
Compiled src/sys/kqueue.erl
Compiled src/sys/inotifywait_win32.erl
Compiled src/sys/fsevents.erl
Compiled src/fs_sup.erl
Compiled src/sys/inotifywait.erl
Compiled src/fs_app.erl
Compiled src/fs_event_bridge.erl
Compiled src/fs_server.erl
Compiled src/fs.erl
==> sync (compile)
Compiled src/sync_options.erl
Compiled src/sync_notify.erl
Compiled src/sync_utils.erl
Compiled src/sync.erl
Compiled src/sync_scanner.erl
==> site (compile)
Compiled src/nitrogen_main_handler.erl
Compiled src/nitrogen_app.erl
Compiled src/nitrogen_sup.erl
Compiled src/mobile.erl
Compiled src/index.erl
==> nitrogen (compile)
make[4]: Leaving directory '/home/xiaolong/dev/erlang/build-it-with-nitrogen/00-install/nitrogen/rel/nitrogen'
make[4]: Entering directory '/home/xiaolong/dev/erlang/build-it-with-nitrogen/00-install/nitrogen/rel/nitrogen'
Generating a default cookie in /etc/vm.args
make[4]: Leaving directory '/home/xiaolong/dev/erlang/build-it-with-nitrogen/00-install/nitrogen/rel/nitrogen'
make[4]: Entering directory '/home/xiaolong/dev/erlang/build-it-with-nitrogen/00-install/nitrogen/rel/nitrogen'
make[4]: Leaving directory '/home/xiaolong/dev/erlang/build-it-with-nitrogen/00-install/nitrogen/rel/nitrogen'
make[3]: Leaving directory '/home/xiaolong/dev/erlang/build-it-with-nitrogen/00-install/nitrogen'
make[2]: Leaving directory '/home/xiaolong/dev/erlang/build-it-with-nitrogen/00-install/nitrogen'
make[2]: Entering directory '/home/xiaolong/dev/erlang/build-it-with-nitrogen/00-install/nitrogen'
make[2]: Leaving directory '/home/xiaolong/dev/erlang/build-it-with-nitrogen/00-install/nitrogen'
make[2]: Entering directory '/home/xiaolong/dev/erlang/build-it-with-nitrogen/00-install/nitrogen'
make[2]: Leaving directory '/home/xiaolong/dev/erlang/build-it-with-nitrogen/00-install/nitrogen'
********************************************************************************
Generated a self-contained Nitrogen project
in ../testproj, configured to run on inets.
********************************************************************************
make[1]: Leaving directory '/home/xiaolong/dev/erlang/build-it-with-nitrogen/00-install/nitrogen'
:end:

Should show:

#+begin_quote
********************************************************************************
Generated a self-contained Nitrogen project
in ../testproj, configured to run on inets.
********************************************************************************
#+end_quote

inets is Erlang's builtin webserver.
